using System;
using System.ComponentModel;
using System.Threading;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.Interfaces;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.Respondents;

namespace FU.Capstones.IMS.Web.Common.InventoryServiceProxy.OperationContracts
{
    public partial class InventoryServiceClient
    {

        #region GetRoleCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Role>> GetRoleCollectionCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetRoleCollection(bool isShowAll, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetRoleCollection(isShowAll, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Role> IInventoryService.EndGetRoleCollection(IAsyncResult result)
        {
            return Channel.EndGetRoleCollection(result);
        }

        private IAsyncResult OnBeginGetRoleCollection(object[] inValues, AsyncCallback callback, object asyncState)
        {
            bool isShowAll = (bool)inValues[0];

            return ((IInventoryService)(this)).BeginGetRoleCollection(isShowAll, callback, asyncState);
        }

        private object[] OnEndGetRoleCollection(IAsyncResult result)
        {
            CollectionFeedback<Role> retVal = ((IInventoryService)(this)).EndGetRoleCollection(result);
            return new object[] { retVal };
        }

        private void OnGetRoleCollectionCompleted(object state)
        {
            if ((GetRoleCollectionCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetRoleCollectionCompleted(this, new CollectionFeedbackCompletedEventArgs<Role>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetRoleCollectionAsync(bool isShowAll)
        {
            GetRoleCollectionAsync(isShowAll, null);
        }

        public void GetRoleCollectionAsync(bool isShowAll, object userState)
        {
            if ((onBeginGetRoleCollectionDelegate == null))
            {
                onBeginGetRoleCollectionDelegate = new BeginOperationDelegate(OnBeginGetRoleCollection);
            }
            if ((onEndGetRoleCollectionDelegate == null))
            {
                onEndGetRoleCollectionDelegate = new EndOperationDelegate(OnEndGetRoleCollection);
            }
            if ((onGetRoleCollectionCompletedDelegate == null))
            {
                onGetRoleCollectionCompletedDelegate = new SendOrPostCallback(OnGetRoleCollectionCompleted);
            }
            InvokeAsync(onBeginGetRoleCollectionDelegate, new object[] {
                    isShowAll}, onEndGetRoleCollectionDelegate, onGetRoleCollectionCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetRoleCollectionDelegate;

        private EndOperationDelegate onEndGetRoleCollectionDelegate;

        private SendOrPostCallback onGetRoleCollectionCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetRoleCollection(bool isShowAll, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = isShowAll;

                IAsyncResult _result = BeginInvoke("GetRoleCollection", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Role> EndGetRoleCollection(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Role> _result = ((CollectionFeedback<Role>)(EndInvoke("GetRoleCollection", _args, result)));
                return _result;
            }
        }

        #endregion
        
        #region GetSingleRole

        public event EventHandler<SingleFeedbackCompletedEventArgs<Role>> GetSingleRoleCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetSingleRole(int roleID, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetSingleRole(roleID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<Role> IInventoryService.EndGetSingleRole(IAsyncResult result)
        {
            return Channel.EndGetSingleRole(result);
        }

        private IAsyncResult OnBeginGetSingleRole(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int roleID = (int)inValues[0];

            return ((IInventoryService)(this)).BeginGetSingleRole(roleID, callback, asyncState);
        }

        private object[] OnEndGetSingleRole(IAsyncResult result)
        {
            SingleFeedback<Role> retVal = ((IInventoryService)(this)).EndGetSingleRole(result);
            return new object[] { retVal };
        }

        private void OnGetSingleRoleCompleted(object state)
        {
            if ((GetSingleRoleCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetSingleRoleCompleted(this, new SingleFeedbackCompletedEventArgs<Role>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetSingleRoleAsync(int roleID)
        {
            GetSingleRoleAsync(roleID, null);
        }

        public void GetSingleRoleAsync(int roleID, object userState)
        {
            if ((onBeginGetSingleRoleDelegate == null))
            {
                onBeginGetSingleRoleDelegate = new BeginOperationDelegate(OnBeginGetSingleRole);
            }
            if ((onEndGetSingleRoleDelegate == null))
            {
                onEndGetSingleRoleDelegate = new EndOperationDelegate(OnEndGetSingleRole);
            }
            if ((onGetSingleRoleCompletedDelegate == null))
            {
                onGetSingleRoleCompletedDelegate = new SendOrPostCallback(OnGetSingleRoleCompleted);
            }
            InvokeAsync(onBeginGetSingleRoleDelegate, new object[] {
                                                                               roleID}, onEndGetSingleRoleDelegate, onGetSingleRoleCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetSingleRoleDelegate;

        private EndOperationDelegate onEndGetSingleRoleDelegate;

        private SendOrPostCallback onGetSingleRoleCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetSingleRole(int roleID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = roleID;

                IAsyncResult _result = BeginInvoke("GetSingleRole", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<Role> EndGetSingleRole(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<Role> _result = ((SingleFeedback<Role>)(EndInvoke("GetSingleRole", _args, result)));
                return _result;
            }
        }

        #endregion

        #region InsertRole

        public event EventHandler<SingleFeedbackCompletedEventArgs<int>> InsertRoleCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginInsertRole(Role data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginInsertRole(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<int> IInventoryService.EndInsertRole(IAsyncResult result)
        {
            return Channel.EndInsertRole(result);
        }

        private IAsyncResult OnBeginInsertRole(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Role data = (Role)inValues[0];

            return ((IInventoryService)(this)).BeginInsertRole(data, callback, asyncState);
        }

        private object[] OnEndInsertRole(IAsyncResult result)
        {
            SingleFeedback<int> retVal = ((IInventoryService)(this)).EndInsertRole(result);
            return new object[] { retVal };
        }

        private void OnInsertRoleCompleted(object state)
        {
            if ((InsertRoleCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                InsertRoleCompleted(this, new SingleFeedbackCompletedEventArgs<int>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void InsertRoleAsync(Role data)
        {
            InsertRoleAsync(data, null);
        }

        public void InsertRoleAsync(Role data, object userState)
        {
            if ((onBeginInsertRoleDelegate == null))
            {
                onBeginInsertRoleDelegate = new BeginOperationDelegate(OnBeginInsertRole);
            }
            if ((onEndInsertRoleDelegate == null))
            {
                onEndInsertRoleDelegate = new EndOperationDelegate(OnEndInsertRole);
            }
            if ((onInsertRoleCompletedDelegate == null))
            {
                onInsertRoleCompletedDelegate = new SendOrPostCallback(OnInsertRoleCompleted);
            }
            InvokeAsync(onBeginInsertRoleDelegate, new object[] {
                                                                            data}, onEndInsertRoleDelegate, onInsertRoleCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginInsertRoleDelegate;

        private EndOperationDelegate onEndInsertRoleDelegate;

        private SendOrPostCallback onInsertRoleCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginInsertRole(Role data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("InsertRole", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<int> EndInsertRole(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<int> _result = ((SingleFeedback<int>)(EndInvoke("InsertRole", _args, result)));
                return _result;
            }
        }

        #endregion

        #region UpdateRole

        public event EventHandler<FeedbackCompletedEventArgs> UpdateRoleCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginUpdateRole(Role data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginUpdateRole(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndUpdateRole(IAsyncResult result)
        {
            return Channel.EndUpdateRole(result);
        }

        private IAsyncResult OnBeginUpdateRole(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Role data = (Role)inValues[0];

            return ((IInventoryService)(this)).BeginUpdateRole(data, callback, asyncState);
        }

        private object[] OnEndUpdateRole(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndUpdateRole(result);
            return new object[] { retVal };
        }

        private void OnUpdateRoleCompleted(object state)
        {
            if ((UpdateRoleCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                UpdateRoleCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void UpdateRoleAsync(Role data)
        {
            UpdateRoleAsync(data, null);
        }

        public void UpdateRoleAsync(Role data, object userState)
        {
            if ((onBeginUpdateRoleDelegate == null))
            {
                onBeginUpdateRoleDelegate = new BeginOperationDelegate(OnBeginUpdateRole);
            }
            if ((onEndUpdateRoleDelegate == null))
            {
                onEndUpdateRoleDelegate = new EndOperationDelegate(OnEndUpdateRole);
            }
            if ((onUpdateRoleCompletedDelegate == null))
            {
                onUpdateRoleCompletedDelegate = new SendOrPostCallback(OnUpdateRoleCompleted);
            }
            InvokeAsync(onBeginUpdateRoleDelegate, new object[] {
                                                                            data}, onEndUpdateRoleDelegate, onUpdateRoleCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginUpdateRoleDelegate;

        private EndOperationDelegate onEndUpdateRoleDelegate;

        private SendOrPostCallback onUpdateRoleCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginUpdateRole(Role data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("UpdateRole", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndUpdateRole(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("UpdateRole", _args, result)));
                return _result;
            }
        }

        #endregion

        #region DeleteRole

        public event EventHandler<FeedbackCompletedEventArgs> DeleteRoleCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginDeleteRole(int data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginDeleteRole(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndDeleteRole(IAsyncResult result)
        {
            return Channel.EndDeleteRole(result);
        }

        private IAsyncResult OnBeginDeleteRole(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int data = (int)inValues[0];

            return ((IInventoryService)(this)).BeginDeleteRole(data, callback, asyncState);
        }

        private object[] OnEndDeleteRole(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndDeleteRole(result);
            return new object[] { retVal };
        }

        private void OnDeleteRoleCompleted(object state)
        {
            if ((DeleteRoleCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                DeleteRoleCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void DeleteRoleAsync(int data)
        {
            DeleteRoleAsync(data, null);
        }

        public void DeleteRoleAsync(int data, object userState)
        {
            if ((onBeginDeleteRoleDelegate == null))
            {
                onBeginDeleteRoleDelegate = new BeginOperationDelegate(OnBeginDeleteRole);
            }
            if ((onEndDeleteRoleDelegate == null))
            {
                onEndDeleteRoleDelegate = new EndOperationDelegate(OnEndDeleteRole);
            }
            if ((onDeleteRoleCompletedDelegate == null))
            {
                onDeleteRoleCompletedDelegate = new SendOrPostCallback(OnDeleteRoleCompleted);
            }
            InvokeAsync(onBeginDeleteRoleDelegate, new object[] {
                                                                            data}, onEndDeleteRoleDelegate, onDeleteRoleCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginDeleteRoleDelegate;

        private EndOperationDelegate onEndDeleteRoleDelegate;

        private SendOrPostCallback onDeleteRoleCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginDeleteRole(int data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("DeleteRole", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndDeleteRole(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("DeleteRole", _args, result)));
                return _result;
            }
        }

        #endregion

        #region SearchRole

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Role>> SearchRoleCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginSearchRole(Role criteria, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginSearchRole(criteria, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Role> IInventoryService.EndSearchRole(IAsyncResult result)
        {
            return Channel.EndSearchRole(result);
        }

        private IAsyncResult OnBeginSearchRole(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Role criteria = (Role)inValues[0];

            return ((IInventoryService)(this)).BeginSearchRole(criteria, callback, asyncState);
        }

        private object[] OnEndSearchRole(IAsyncResult result)
        {
            CollectionFeedback<Role> retVal = ((IInventoryService)(this)).EndSearchRole(result);
            return new object[] { retVal };
        }

        private void OnSearchRoleCompleted(object state)
        {
            if ((SearchRoleCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                SearchRoleCompleted(this, new CollectionFeedbackCompletedEventArgs<Role>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void SearchRoleAsync(Role criteria)
        {
            SearchRoleAsync(criteria, null);
        }

        public void SearchRoleAsync(Role criteria, object userState)
        {
            if ((onBeginSearchRoleDelegate == null))
            {
                onBeginSearchRoleDelegate = new BeginOperationDelegate(OnBeginSearchRole);
            }
            if ((onEndSearchRoleDelegate == null))
            {
                onEndSearchRoleDelegate = new EndOperationDelegate(OnEndSearchRole);
            }
            if ((onSearchRoleCompletedDelegate == null))
            {
                onSearchRoleCompletedDelegate = new SendOrPostCallback(OnSearchRoleCompleted);
            }
            InvokeAsync(onBeginSearchRoleDelegate, new object[] {
                                                                            criteria}, onEndSearchRoleDelegate, onSearchRoleCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginSearchRoleDelegate;

        private EndOperationDelegate onEndSearchRoleDelegate;

        private SendOrPostCallback onSearchRoleCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginSearchRole(Role criteria, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = criteria;

                IAsyncResult _result = BeginInvoke("SearchRole", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Role> EndSearchRole(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Role> _result = ((CollectionFeedback<Role>)(EndInvoke("SearchRole", _args, result)));
                return _result;
            }
        }

        #endregion

        #region UndoDeleteRole

        public event EventHandler<FeedbackCompletedEventArgs> UndoDeleteRoleCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginUndoDeleteRole(int objID, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginUndoDeleteRole(objID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndUndoDeleteRole(IAsyncResult result)
        {
            return Channel.EndUndoDeleteRole(result);
        }

        private IAsyncResult OnBeginUndoDeleteRole(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int objID = (int)inValues[0];

            return ((IInventoryService)(this)).BeginUndoDeleteRole(objID, callback, asyncState);
        }

        private object[] OnEndUndoDeleteRole(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndUndoDeleteRole(result);
            return new object[] { retVal };
        }

        private void OnUndoDeleteRoleCompleted(object state)
        {
            if ((UndoDeleteRoleCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                UndoDeleteRoleCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void UndoDeleteRoleAsync(int objID)
        {
            UndoDeleteRoleAsync(objID, null);
        }

        public void UndoDeleteRoleAsync(int objID, object userState)
        {
            if ((onBeginUndoDeleteRoleDelegate == null))
            {
                onBeginUndoDeleteRoleDelegate = new BeginOperationDelegate(OnBeginUndoDeleteRole);
            }
            if ((onEndUndoDeleteRoleDelegate == null))
            {
                onEndUndoDeleteRoleDelegate = new EndOperationDelegate(OnEndUndoDeleteRole);
            }
            if ((onUndoDeleteRoleCompletedDelegate == null))
            {
                onUndoDeleteRoleCompletedDelegate = new SendOrPostCallback(OnUndoDeleteRoleCompleted);
            }
            InvokeAsync(onBeginUndoDeleteRoleDelegate, new object[] {
                    objID}, onEndUndoDeleteRoleDelegate, onUndoDeleteRoleCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginUndoDeleteRoleDelegate;

        private EndOperationDelegate onEndUndoDeleteRoleDelegate;

        private SendOrPostCallback onUndoDeleteRoleCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginUndoDeleteRole(int objID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = objID;

                IAsyncResult _result = BeginInvoke("UndoDeleteRole", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndUndoDeleteRole(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("UndoDeleteRole", _args, result)));
                return _result;
            }
        }

        #endregion
        
    }
}